using System;
using System.Globalization;

using NUnit.Framework;

namespace HabilisDesign.Iota.UnitTests
{
    [TestFixture]
    public class StatusTests
    {
        [Test]
        public void TestConstructorDecodesXmlWithoutUser()
        {
            string testXml = "<status><created_at>Thu Apr 12 12:48:05 +0000 2007</created_at><id>987654321</id><text>This is a test status. Are you getting it??</text></status>";
            Status testStatus = Status.Parse( testXml );
            Assert.AreEqual( DateTime.ParseExact( "Thu Apr 12 12:48:05 +0000 2007", "ddd MMM dd HH:mm:ss zzzzz yyyy", CultureInfo.InvariantCulture ), testStatus.CreatedAt );
            Assert.AreEqual( "987654321", testStatus.Id );
            Assert.AreEqual( "This is a test status. Are you getting it??", testStatus.Text );
        }

        [Test]
        public void TestConstructorDecodesXmlWithUser()
        {
            string testXml = "<status><created_at>Thu Apr 12 12:48:05 +0000 2007</created_at><id>987654321</id><text>This is a test status. Are you getting it??</text><user><id>12345678</id><name>testuser</name><screen_name>Test User</screen_name><location>Flower Mound, Texas</location><description>Bent on adding beauty to the world</description><profile_image_url>http://assets3.twitter.com/system/user/profile_image/12345678/normal/pic.png?1171960310</profile_image_url><url>http://testing.com</url><protected>false</protected></user></status>";
            Status testStatus = Status.Parse( testXml );
            Assert.AreEqual( DateTime.ParseExact( "Thu Apr 12 12:48:05 +0000 2007", "ddd MMM dd HH:mm:ss zzzzz yyyy", CultureInfo.InvariantCulture ), testStatus.CreatedAt );
            Assert.AreEqual( "987654321", testStatus.Id );
            Assert.AreEqual( "This is a test status. Are you getting it??", testStatus.Text );
            Assert.AreEqual( "12345678", testStatus.User.Id );
            Assert.AreEqual( "testuser", testStatus.User.Name );
            Assert.AreEqual( "Test User", testStatus.User.ScreenName );
            Assert.AreEqual( "Flower Mound, Texas", testStatus.User.Location );
            Assert.AreEqual( "Bent on adding beauty to the world", testStatus.User.Description );
            Assert.AreEqual( new Uri( "http://assets3.twitter.com/system/user/profile_image/12345678/normal/pic.png?1171960310" ), testStatus.User.ProfileImage );
            Assert.AreEqual( new Uri( "http://testing.com" ), testStatus.User.Url );
            Assert.IsFalse( testStatus.User.Protected );
        }

    } // end class

} // end namespace
